package com.wn.consumer.consumer05;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author yellow Docter
 * @date 2022 -08-31
 * @desc
 *
 *  rpc的模式
 *    远程模式
 *
 * 01 当前的消费者 是  消息者
 *
 * 02 把这个消息进行处理 返回结果 (消息提供者 )
 *    消息服务端
 */
@Component
@Slf4j
public class Server {

    @RabbitListener(
            bindings = @QueueBinding(
                    value = @Queue("rpc-queue"),
                    exchange = @Exchange(
                            name = "exchange-rpc",
                            type = ExchangeTypes.DIRECT
                    ),
                    key = "rpc"
            )
    )
    public String consumerAndService(String msg){
        log.info("消费者消费了消息:{}",msg);
        return msg + ",服务端处理消息,返回结果";
    }
}
